<template>
	<view>
		<van-field v-if="!useCustom" :value="address" :required="true" placeholder="请选择地址" error-message-align="right"
			:error-message="errors.address" is-link clickable readonly input-align="right"
			@click-input="toSelectAddress">
			<view slot="label" class="color8">
				收货地址
			</view>
		</van-field>
		<slot></slot>
		<van-field v-if="!useCustom" :value="bonus" :required="true" placeholder="请输入金额" input-align="right"
			error-message-align="right" :error-message="errors.bonus" @change="onChangeBonus">
			<viwe slot="label" class="t-14">
				金额
			</viwe>
		</van-field>
	</view>
</template>

<script>
	export default {
		name: "ppl-infoField",
		props: {
			useCustom: {
				type: Boolean,
				default: false
			},
			address: {
				type: String,
				default: ''
			},
			bonus: {
				type: String,
				default: ''
			},
			errors: {
				type: Object,
				default: {}
			}

		},
		data() {
			return {
				bonus: ''
			};
		},
		methods: {
			onChangeBonus(e) {
				this.bonus = e.detail;
				this.$emit('change', this.bonus)
			},
			toSelectAddress() {
				uni.navigateTo({
					url: '/package/pages/address/address'
				})
			}
		}
	}
</script>

<style scoped>


</style>